import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

export const constantRouterMap = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/ec/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '系统首页', icon: 'dashboard', noCache: true },
        hidden: true
      }
    ],
    hidden: true
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // 系统管理
  {
    path: '/system',
    component: Layout,
    name: 'System',
    meta: { title: '系统管理', icon: 'form' },
    children: [
      {
        path: 'index',
        component: () => import('@/views/fy/dashboard/user'),
        name: 'System',
        meta: { title: '系统用户管理', icon: 'form' }
      },
      {
        path: 'role',
        component: () => import('@/views/fy/dashboard/role'),
        name: 'systemUser',
        meta: { title: '系统角色管理', icon: 'form' }
      },
      {
        path: 'roledetail',
        component: () => import('@/views/fy/dashboard/roledetail'),
        name: 'systemUser',
        meta: { title: '新增角色', icon: 'form' },
        hidden: true
      },
      {
        path: 'roledetail/:id',
        component: () => import('@/views/fy/dashboard/roledetail'),
        name: 'systemUser',
        meta: { title: '修改角色', icon: 'form' },
        hidden: true
      },
      {
        path: 'area',
        component: () => import('@/views/fy/dashboard/area'),
        name: 'Role',
        meta: { title: '区域管理', icon: 'form' }
      }
    ]
  },
  // 项目管理
  {
    path: '/project',
    component: Layout,
    name: 'Project',
    meta: { title: '项目管理', icon: 'form' },
    children: [
      {
        path: 'index',
        component: () => import('@/views/fy/project/index'),
        name: 'Project',
        meta: { title: '楼盘管理', icon: 'form' }
      },
      {
        path: 'createbuilding',
        component: () => import('@/views/fy/project/createbuilding'),
        name: 'CreateBuilding',
        meta: { title: '新增楼旁', icon: 'form' },
        hidden: true
      },
      {
        path: 'createbuilding/:id',
        component: () => import('@/views/fy/project/createbuilding'),
        name: 'CreateBuilding',
        meta: { title: '新增楼旁', icon: 'form' },
        hidden: true
      },
      {
        path: 'video',
        component: () => import('@/views/fy/project/video'),
        name: 'Video',
        meta: { title: '视频管理', icon: 'form' }
      }
    ]
  },
  // 预约管理
  {
    path: '/appointment',
    component: Layout,
    name: 'Appointment',
    meta: { title: '预约管理', icon: 'form' },
    children: [
      {
        path: 'index',
        component: () => import('@/views/fy/appointment/index'),
        name: 'Appointment',
        meta: { title: '预约管理', icon: 'form' }
      }
    ]
  },
  // 资讯管理
  {
    path: '/news',
    component: Layout,
    name: 'News',
    meta: { title: '资讯管理', icon: 'form' },
    children: [
      {
        path: 'category',
        component: () => import('@/views/fy/news/category'),
        name: 'Category',
        meta: { title: '分类管理', icon: 'form' }
      },
      {
        path: 'index',
        component: () => import('@/views/fy/news/index'),
        name: 'Project',
        meta: { title: '发布管理', icon: 'form' }
      },
      {
        path: 'createnews',
        component: () => import('@/views/fy/news/createnews'),
        name: 'CreateBuilding',
        meta: { title: '新增资讯', icon: 'form' },
        hidden: true
      },
      {
        path: 'createnews/:id',
        component: () => import('@/views/fy/news/createnews'),
        name: 'CreateBuilding',
        meta: { title: '修改资讯', icon: 'form' },
        hidden: true
      }
    ]
  },
  // 运营
  {
    path: '/operate',
    component: Layout,
    name: 'Operate',
    meta: { title: '运营管理', icon: 'form' },
    children: [
      {
        path: 'home',
        component: () => import('@/views/fy/operate/home'),
        name: 'Home',
        meta: { title: '首页设置', icon: 'form' }
      },
      {
        path: 'homesetting/:id',
        component: () => import('@/views/fy/operate/homesetting'),
        name: 'HomeSetting',
        meta: { title: '首页设置', icon: 'form' },
        hidden: true
      },
      {
        path: 'ad',
        component: () => import('@/views/fy/operate/ad'),
        name: 'Coupon',
        meta: { title: '广告管理', icon: 'form' }
      },
      {
        path: 'adsetting/:id',
        component: () => import('@/views/fy/operate/adsetting'),
        name: 'HomeSetting',
        meta: { title: '广告设置', icon: 'form' },
        hidden: true
      },
      {
        path: 'adviser',
        component: () => import('@/views/fy/operate/adviser'),
        name: 'Coupon',
        meta: { title: '置业顾问管理', icon: 'form' }
      },
      {
        path: 'callcard',
        component: () => import('@/views/fy/operate/callcard'),
        name: 'CallCard',
        meta: { title: '名片管理', icon: 'form' }
      },
      {
        path: 'addCallcard',
        component: () => import('@/views/fy/operate/addCallcard'),
        name: 'CallCard',
        meta: { title: '名片新增', icon: 'form' },
        hidden: true
      },
      {
        path: 'user',
        component: () => import('@/views/fy/operate/user'),
        name: 'User',
        meta: { title: '用户管理', icon: 'form' }
      },
      {
        path: 'activity',
        component: () => import('@/views/fy/operate/activity'),
        name: 'Activity',
        meta: { title: '活动管理', icon: 'form' }
      },
      {
        path: 'createactivity',
        component: () => import('@/views/fy/operate/createactivity'),
        name: 'Activity',
        meta: { title: '新增活动', icon: 'form' },
        hidden: true
      },
      {
        path: 'createactivity/:id',
        component: () => import('@/views/fy/operate/createactivity'),
        name: 'Activity',
        meta: { title: '修改活动', icon: 'form' },
        hidden: true
      },
      {
        path: 'coupon',
        component: () => import('@/views/fy/operate/coupon'),
        name: 'Activity',
        meta: { title: '优惠劵管理', icon: 'form' }
      },
      {
        path: 'createcoupon',
        component: () => import('@/views/fy/operate/createcoupon'),
        name: 'Activity',
        meta: { title: '新增优惠劵', icon: 'form' },
        hidden: true
      }
      // {
      //     path: 'integralrule',
      //     component: () => import('@/views/fy/operate/integralrule'),
      //     name: 'Integralrule',
      //     meta: { title: '积分规则', icon: 'form' }
      // },
      // {
      //     path: 'integral',
      //     component: () => import('@/views/fy/operate/integral'),
      //     name: 'Integral',
      //     meta: { title: '积分管理', icon: 'form' }
      // },
      // {
      //     path: 'integralmall',
      //     component: () => import('@/views/fy/operate/integralmall'),
      //     name: 'Integralmall',
      //     meta: { title: '积分商城管理', icon: 'form' }
      // }
    ]
  },
  // 界面
  {
    path: '/message',
    component: Layout,
    name: 'Page',
    meta: { title: '客服管理', icon: 'form' },
    children: [
      {
        path: 'index',
        component: () => import('@/views/fy/message/index'),
        name: 'productdetail',
        meta: { title: '消息管理', icon: 'form' }
      },
      {
        path: 'record',
        component: () => import('@/views/fy/message/record'),
        name: 'productdetail',
        meta: { title: '客户咨询管理', icon: 'form' }
      }
    ]
  },
  /** When your routing table is too long, you can split it into small modules**/
  { path: '*', redirect: '/404', hidden: true }
]
